\documentclass[a4paper]{article}
\usepackage[affil-it]{authblk}
\usepackage[backend=bibtex,style=numeric]{biblatex}
\usepackage{amsmath}  
\usepackage{indentfirst}
\usepackage{geometry}
\usepackage{amsthm}
\usepackage{titlesec}  
\usepackage{graphicx}
\newtheorem*{acknowledgements}{Acknowledgements} 
\usepackage{multirow}
\BeforeBeginEnvironment{abstract}{\vspace{-25pt}}  
\titlespacing{\section}{0pt}{\parskip}{-\parskip}  
\geometry{margin=1.5cm, vmargin={0pt,1cm}}
\setlength{\topmargin}{-1cm}
\setlength{\paperheight}{29.7cm}
\setlength{\textheight}{25.3cm}

\addbibresource{citation.bib}

\begin{document}
% =================================================
\title{Numerical Analysis report 2}

\author{YanYuqing 3220104804
  \thanks{Electronic address:\texttt{3220104804@zju.edu.cn}}}
\affil{statistics 2201, Zhejiang University }


\date{}

\maketitle

\begin{abstract}  
The assignments covered a range of topics including polynomial interpolation, the Runge phenomenon, Chebyshev interpolation, Hermite interpolation, and Bezier curve approximations. Each assignment was implemented in a programming language and the results were plotted to validate the theoretical concepts discussed in the lecture notes.
\end{abstract} 

\section*{Problem A}
We initially define a virtual function class named Function. Both Newton interpolation polynomial and Hermite interpolation polynomial inherit from this class. We utilize a divided difference table to calculate the interpolation polynomial, where $z$ stores the divided difference values. The most critical step in the initialization process is the recursive computation of the divided difference table and assigning the diagonal elements to $z$. The computation of the Newton divided difference table is relatively straightforward, while the Hermite interpolation is more complex. We need to sort the variables, group identical variables together, analyze, and construct the divided difference table. The specific implementation details can be found in the code. In addition to the interpolation computation, the polynomial interpolation class also includes methods for evaluation and derivative calculation, with the derivative computed using an approximation method. 

In the Bezier curve class, we accept a list of points and a list of derivatives. In the solution of problem F, we will see that controlling the appropriate proportion of the derivative list is crucial for drawing a good graph. The member variables of the Bezier curve class are the control point coordinates, which is a three-dimensional array to meet the algorithm's requirements. We also define the Bernstein basis polynomials.

Meanwhile, we design a text.cpp to ensure the correctness of the Classes. The results are as follows:
\begin{verbatim}
    4.36753
    4.36753
\end{verbatim}



\section*{Problem B \& C}
These two problems can be solved by generating data based on the function and plotting with Python.

The figures are as follows.
\begin{figure}[h]
  \centering
  \includegraphics[width=0.8\textwidth]{./picture/2B.png} % 插入图片，宽度为文本宽度的一半
  \caption{Fig 1} % 图片的标题
\end{figure}

\begin{figure}[h]
  \centering
  \includegraphics[width=0.8\textwidth]{./picture/2C.png} % 插入图片，宽度为文本宽度的一半
  \caption{Fig 2} % 图片的标题
\end{figure}

\section*{Problem D}
In this problem, we employed Hermite interpolation for the function. By applying evaluation and differentiation operators, we obtained the answer to the first question. For the second question, we utilized a small interval traversal method. The continuity of the function ensures the rationality of the algorithm, ultimately leading to the conclusion that there must be periods of speeding within the interval.

\begin{verbatim}
Predicted position at t = 10 seconds: 742.503 feet
Predicted velocity at t = 10 seconds: 48.3817 feet/second
Predicted velocity at t = 5.92 seconds: 81.0073 feet/second
The car exceed the speed limit.
\end{verbatim}



\section*{Problem E}
For this problem, we construct vectors for several interpolation points and the Newton interpolation function. We then use a traversal method similar to the previous problem to find the minimum value. Based on this minimum value, we can determine whether death occurs.
\begin{verbatim}
Predicted min weight of Sp1 at day 43: 28.7
Predicted min weight of Sp2 at day 43: 8.89
Sp1 is predicted to survive after 15 more days.
Sp2 is predicted to survive after 15 more days.
\end{verbatim}

\section*{Problem F}
This problem presents a significant challenge, which we address by leveraging the Bezier class and Algorithm 2.74 from the textbook. During the implementation of the code, several details require special attention:

\begin{enumerate}
    \item Apply a small perturbation to the interpolation points to avoid selecting singular points.
    \item Initialize the tangent vectors based on the interpolation spacing ratio to prevent self-intersection due to excessive magnitude.
\end{enumerate}

By adhering to these considerations, we can plot a reasonably good approximate curve, as shown in the figure below:
\begin{figure}[h]
  \centering
  \includegraphics[width=0.8\textwidth]{./picture/2F.png} % 插入图片，宽度为文本宽度的一半
  \caption{Fig 3} % 图片的标题
\end{figure}



\begin{acknowledgements}  

I would like to express my gratitude to my roommate Wang Hao for his guidance on the algorithm implementation of my Problem F.

\end{acknowledgements}

\end{document}